package Operation;

import book.Book;
import book.BookList;
import javafx.scene.transform.Scale;

import java.util.Scanner;

public class AddOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("新增图书");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入新增图书的名字：");
        String name = scanner.nextLine();
        System.out.println("图书作者：");
        String author = scanner.nextLine();
        System.out.println("图书类型");
        String type = scanner.nextLine();
        System.out.println("图书价格：");
        int price = scanner.nextInt();
//        System.out.println("图书类型");
//        String type = scanner.nextLine();//但是在java里面最好是先输入字符串再输数字，不然会将图书类型认为是一个回车
        Book book = new Book(name,author,price,type);
        int currentSize = bookList.getUsedSize();
        bookList.setBooks(currentSize,book);
        bookList.setUsedSize(currentSize+1);
        System.out.println("图书新增成功！");
//        scanner.close();
    }//新增图书功能的实现就是业务逻辑
}
